package com.dyna.listener;

import com.dyna.constants.EsIndicesConstant;
import com.dyna.core.event.DynaGlobalExceptionEvent;
import com.dyna.utils.EsUtil;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author zhoucaiwang
 * @date 2024/1/10
 */
@Component
public class DynaGlobalExceptionListener {

    @Async
    @EventListener(classes = DynaGlobalExceptionEvent.class)
    public void saveLoginUserInfo(DynaGlobalExceptionEvent globalExceptionEvent) {
        EsUtil.initIndex(EsIndicesConstant.ERROR_INFO_INDEX);
        EsUtil.addData(EsIndicesConstant.ERROR_INFO_INDEX, globalExceptionEvent.getDynaGlobalExceptionEntity());
    }

}
